package pack1;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Scanner;

public class QueryStringBuider {

	String location;
	String PathFor04Days;
	String PathFor25Days;
	String PathForMasterFile;

	public QueryStringBuider(String location) throws IOException {
		super();
		this.location = location;
		generatePaths(location);
	}

	void generatePaths(String location) throws IOException {

		Scanner sc = new Scanner(new BufferedReader(new FileReader(location)));

		this.PathFor04Days = sc.nextLine();
		this.PathFor25Days = sc.nextLine();
		this.PathForMasterFile = sc.nextLine();

		sc.close();
	}

	String buildQueryFor04Days() throws FileNotFoundException {

		Scanner sc = new Scanner(new BufferedReader(new FileReader(
				PathFor04Days)));
		String QueryFor04Days = "";
		while (sc.hasNext()) {

			QueryFor04Days = QueryFor04Days + "\n " + sc.nextLine();

		}

		sc.close();

		// System.out.println("QueryFor04Days  ::" + QueryFor04Days);

		return QueryFor04Days;
	}

	String buildQueryFor25Days() throws FileNotFoundException {

		// System.out.println(PathFor25Days);
		Scanner sc = new Scanner(new BufferedReader(new FileReader(
				PathFor25Days)));
		String QueryFor25Days = "";
		while (sc.hasNext()) {

			QueryFor25Days = QueryFor25Days + "\n " + sc.nextLine();

		}

		sc.close();

		return QueryFor25Days;
	}

	String buildQueryForMasterFile() throws FileNotFoundException {

		// System.out.println(PathFor25Days);
		Scanner sc = new Scanner(new BufferedReader(new FileReader(
				PathForMasterFile)));
		String QueryForMasterFile = "";
		while (sc.hasNext()) {

			QueryForMasterFile = QueryForMasterFile + "\n " + sc.nextLine();

		}

		sc.close();

		return QueryForMasterFile;
	}

	public static void main(String[] args) throws IOException {

		QueryStringBuider qsb = new QueryStringBuider(
				"D:/Project/Market_Intelligence_Project/misc/Database_Queries/paths.txt");

		System.out.println(qsb.buildQueryFor04Days());
		System.out.println(qsb.buildQueryFor25Days());
	 System.out.println(qsb.buildQueryForMasterFile());

	}

}
